#ifndef IMOVABLEENTITYBEHAVIOUR_H
#define IMOVABLEENTITYBEHAVIOUR_H

#include <list>
#include "../include/IDefaultEntityBehaviour.h"
#include "../include/CDefaultShotBehaviour.h"

class CSpriteAnimation;
struct SDL_Surface;

//**************************
//Manage the behaviour of any "movable" entity (like a player or an enemy)
//**************************
class IMovableEntityBehaviour : public IDefaultEntityBehaviour
{
    protected:
        std::list<CDefaultShotBehaviour *> * m_vShots;	//Contains shot of the entity
        int m_iCurrentNumLives;                             //Current number of life of the entity
        int m_iNumLives;                                    //number of lives that the entity have

        //type of shot on the primary and the secondary shot
        int m_iPrimaryShot;
        int m_iSecondaryShot;

        //last times a player shot
        long m_lLastPrimaryShoot;                    //last time the entity shot a primary shot
        long m_lLastSecondaryShoot;                    //last time the entity shot a secondary shot

        //These times are not ine define because it depends on the entity
        int m_iTimeBetweenPrimaryShot;  //compulsory times to wait after the entity can shot another primary shot
        int m_iTimeBetweenSecondaryShot;  //compulsory times to wait after the entity can shot another secondary shot

    public:
        //**************************
        //Description : Constructor
        //Parameters : Value for m_iX, m_iY,
        //              m_iSpeedX, m_iSpeedY,
        //              m_iWidth, m_iHeight,
        //              the ratio for the collision box
        //              the type of colision
        //              m_iLives
        //Note : None
        //**************************
        IMovableEntityBehaviour(int _iX = 0, int _iY = 0,
                                int _iSpeedX = 0, int _iSpeedY = 0,
                                int _iWidth = 0, int _iHeight = 0,
                                float _fRatioW = 0.0f, float _fRatioH = 0.0f,
                                TYPE_COLLISION _iTypeCollision = AIR,
                                int _iLives = 0);

        //**************************
        //Description : Copy Constructor
        //Parameters : A IMovableEntityBehaviour
        //Note : None
        //**************************
        IMovableEntityBehaviour(IMovableEntityBehaviour & _MovableEntity);

        //**************************
        //Description : Destructor
        //Parameters : None
        //Note : None
        //**************************
        virtual ~IMovableEntityBehaviour();

        //**************************
        //Description : Restore the current lives to the initial number
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void RestoreLife();

        //**************************
        //Description : Return the current number of lives
        //Parameters : None
        //Return Value : The current number of lives
        //Note : None
        //**************************
        int HasLives() const;

        //**************************
        //Description : Give _iNumLives to m_iNumLives
        //Parameters : The number of lives
        //Return Value : None
        //Note : None
        //**************************
        void AddLife(int _iNumLives = 1);

        //**************************
        //Description : Decrease m_iNumLives of _iNumLives
        //Parameters : The number of lives
        //Return Value : None
        //Note : None
        //**************************
        void LoseLife(int _iNumLives = 1);

        //**************************
        //Description : Return whether the entity is dead or not
        //Parameters : None
        //Return Value : True if _iLives == 0, otherwise false
        //Note : None
        //**************************
        bool IsDead() const;

        //**************************
        //Description : The entity shoot
        //Parameters : The tab of animations shot and the screen
        //Return Value : True if the enemy has shot, otherwise false
        //Note : Virtual because the way of shooting depends on the entity
        //**************************
        virtual bool Shoot(CSpriteAnimation * _SpriteAnimationShot, SDL_Surface * _screen) = 0;

        //**************************
        //Description : Erase all the shots
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void ClearShots();

        //**************************
        //Description : Return the shots of the entity
        //Parameters : None
        //Return Value : shots of the entity or NULL if none
        //Note : None
        //**************************
        std::list<CDefaultShotBehaviour *> * HasShots();

        //**************************
        //Description : A shot is out of the screen or collides with an entity, we pop it out
        //Parameters : The shot to pop out of the list
        //Return Value : The iterator after the pop
        //Note : None
        //**************************
        std::list<CDefaultShotBehaviour *>::iterator PopShot(std::list<CDefaultShotBehaviour *>::iterator _Shot);

        //**************************
        //Description : Pop out of the list all shots that are not in the screen anymore
        //Parameters : None
        //Return Value : None
        //Note : None
        //**************************
        void PopShotOutOfScreen();

        //**************************
        //Description : Update the trajectory of the entity
        //Parameters : None
        //Return Value : None
        //Note : Virtual because actions depends on the entity type
        //**************************
        virtual void EntityTrajectory() = 0;
};
#endif
